package com.ys.nms.module.business.dal.mysql.localCompanyArea;
import com.ys.nms.framework.mybatis.core.mapper.BaseMapperX;
import com.ys.nms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ys.nms.module.business.controller.admin.localCompanyArea.vo.CompanyAreaListReqVO;
import com.ys.nms.module.business.dal.dataobject.localCompanyArea.CompanyAreaDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 区域 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface CompanyAreaMapper extends BaseMapperX<CompanyAreaDO> {

    default List<CompanyAreaDO> selectList(CompanyAreaListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CompanyAreaDO>()
                .likeIfPresent(CompanyAreaDO::getName, reqVO.getName())
                .likeIfPresent(CompanyAreaDO::getDutyUserName, reqVO.getDutyUserName())
                .eqIfPresent(CompanyAreaDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CompanyAreaDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CompanyAreaDO::getSort));
    }

	default CompanyAreaDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(CompanyAreaDO::getParentId, parentId, CompanyAreaDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(CompanyAreaDO::getParentId, parentId);
    }

}